<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
require_once("../conn.php");

$task = $_POST['task'];
$gold = $_POST['gold'];

$num = count($task);

$db = new DBC();
$return = true;
for ($i = 0; $i < $num; $i++) {
    $sql = "UPDATE t_task_info SET gold = " . $gold[$i] . " WHERE task = '" . $task[$i] . "'";
    if (!$db->execute($sql)) {
        $return = false;
    }
}
$transfer = "taskList.php?menu=task";
if ($return) {
    //success
    echo "<script language='javascript'>location='" . $transfer . "';</script>";
} else {
    //failue
    echo "<script language='javascript'>alert('失败'); </script>";
    echo "<script language='javascript'>history.back();</script>";
}
?>
